require(["dijit/form/ComboBox", "dijit/form/Button", "dojo/dom", "dojo/json", "dojo/request", "dojo/_base/window",
	"dojo/_base/declare", "dojo/parser", "dijit/_WidgetBase", "dijit/_TemplatedMixin", "dijit/registry", "dojo/store/Memory"], 
	function(ComboBox, Button, dom, JSON, request, win, declare, parser, _WidgetBase, _TemplatedMixin, registry, Memory){
		
		declare("SelectColumn", [_WidgetBase, _TemplateMixin], {
			templateString:
				"<span data-dojo-type='dijit/form/ComboBox' id='selectcolumn' name='selectcolumn' " +
				"data-dojo-attach-event='onclose: changeChart' placeHolder='Select Column' searchAttr='name'></span>",
			
			changeChart: function() {
			
			}
			
			update: function(table){
				request.post("columns", {
					data: JSON.stringify({opType: "getTableColumns", value: table}),
					handleAs: "json"}).then(function(data){
						var fields = [];
						for (var i = 0; i < data.length; i++) {
							var item = data[i];
							fields = fields.concat([{name:item, id:item}]);
						}
						var items = {data:fields};
						var dataStore = new Memory(items);
					});
				}
		});
		
		ready(function() {
		
			parser.parse();
		
		});
	});
